package com.mark.musicbox;

import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class ActivityModuleDownload extends ActivityGroup implements
		View.OnClickListener {
	LinearLayout contain = null;
	ImageView tabDownload = null;
	ImageView tabDowning = null;
	LocalActivityManager m = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.module_download);
		contain = (LinearLayout) findViewById(R.id.musicContain);
		tabDownload = (ImageView) findViewById(R.id.tab_download);
		tabDowning = (ImageView) findViewById(R.id.tab_downing);
		m = getLocalActivityManager();
		tabDownload.setOnClickListener(this);
		tabDowning.setOnClickListener(this);
		Intent intent = new Intent();
		intent.setClass(ActivityModuleDownload.this, ActivityMusicList.class);
		Window w = m.startActivity("containActivity1", intent);
		contain.addView(w.getDecorView());
	}

	public void onClick(View v) {
		Intent intent = new Intent();
		switch (v.getId()) {
		case R.id.tab_download:
			tabDownload.setImageResource(R.drawable.top_tab_download_default);
			tabDowning.setImageResource(R.drawable.top_tab_downing_press);
			intent.setClass(ActivityModuleDownload.this, ActivityMusicList.class);
			Window w = m.startActivity("containActivity1", intent);
			contain.removeAllViews();
			contain.addView(w.getDecorView());
			break;
		case R.id.tab_downing:
			tabDownload.setImageResource(R.drawable.top_tab_download_press);
			tabDowning.setImageResource(R.drawable.top_tab_downing_default);
			intent.setClass(ActivityModuleDownload.this, ActivityMusicList.class);
			w = m.startActivity("containActivity1", intent);
			contain.removeAllViews();
			contain.addView(w.getDecorView());
			break;

		}
	}
}
